package com.spzx.cart.api.factory;

import com.spzx.cart.api.RemoteCartService;
import com.spzx.cart.api.domain.CartInfo;
import com.spzx.common.core.domain.R;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author LOGIN
 * @title RemoteCartFallBackFactory
 * @create 2025/7/28 1:55
 * @description
 *
 *    购物车降级处理逻辑
 */
public class RemoteCartFallBackFactory implements FallbackFactory<RemoteCartService> {
    @Override
    public RemoteCartService create(Throwable cause) {
        return new RemoteCartService() {
            @Override
            public R<List<CartInfo>> getCartCheckedList(String source) {
                return R.fail("获取购物车中选中数据失败" + cause.getMessage());
            }

            @Override
            public R<Boolean> deleteCartCheckedList(String source) {
                return R.fail("删除购物车中选中数据失败" + cause.getMessage());
            }

            @Override
            public R<Boolean> updateCartPrice(String source) {
                return R.fail("更新购物车价格失败" + cause.getMessage());
            }
        };
    }
}
